#include "portInfo.h"

#include <ctime>
// 将 PortStatus 转换为字符串
char* portStatusToString(PortStatus state) {
    switch (state) {
        case OPEN: return "OPEN";
        case CLOSED: return "CLOSED";
        case FILTERED: return "FILTERED";
        case OPEN_FILTERED: return "OPEN_FILTERED";
        case CLOSED_FILTERED: return "CLOSED_FILTERED";
        default: return "UNKNOWN";
    }
}

// 获取当前时间并格式化为字符串
char* getCurrentTime() {
    std::time_t now = std::time(nullptr);
    char buffer[80];
    std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", std::localtime(&now));
    return buffer;
}
